/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aybolit.core.objects;

import aybolit.core.objects.dao.HealthingDao;
import aybolit.core.objects.dao.HealthingSymptomsDao;
import aybolit.core.objects.dao.SymptomsDao;
import aybolit.core.objects.model.Healing;
import aybolit.core.objects.model.HealingSymptoms;
import aybolit.core.objects.model.Symptoms;
import java.io.Serializable;
import java.util.*;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

/**
 *
 * @author Masumov Emin
 */
public class HealthingSymptomsBean implements Serializable {

    private Date data;
    private Map<String, String> symptoms = new HashMap<String, String>();
    private List<HealingSymptoms> sympList;
    HealthingSymptomsDao healthingSymptomsDaoImp;
    SymptomsDao symptomsDao;
    private String sympId;
    HealthingDao healthingDaoImp;
    private String value;

    public List<HealingSymptoms> healthingSymptomsByPacientId() {
        HttpSession ses = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
        String id = (String) ses.getAttribute("pacientID");
        System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!! pacient ID" + id);
        sympList = healthingSymptomsDaoImp.findHealingSymptomsByPacientId(id);
        return sympList;
    }

    public Map<String, String> getSymptom111() {
        List<Symptoms> list = symptomsDao.findAllSymptoms();
        for (Iterator iter = list.iterator(); iter.hasNext();) {
            Symptoms symp = (Symptoms) iter.next();
            symptoms.put(symp.getName(), String.valueOf(symp.getSymptomId()));
        }
        return symptoms;
    }

    public void save() {
        HealingSymptoms sympt = new HealingSymptoms();
        HttpSession ses = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
        String id = (String) ses.getAttribute("pacientID");
        Healing heal = healthingDaoImp.findHellingByPacientId(id);
        sympt.setStatus(0);
        sympt.setSymptomId(Integer.parseInt(sympId));
//        java.sql.Timestamp t = new java.sql.Timestamp(data.getTime());
//        sympt.setTimestamp(t);
        sympt.setValue(value);
        sympt.setHealingId(heal.getHealingId());
        healthingSymptomsDaoImp.save(sympt);
    }

    public HealthingSymptomsDao getHealthingSymptomsDaoImp() {
        return healthingSymptomsDaoImp;
    }

    public void setHealthingSymptomsDaoImp(HealthingSymptomsDao healthingSymptomsDaoImp) {
        this.healthingSymptomsDaoImp = healthingSymptomsDaoImp;
    }

    public Map<String, String> getSymptoms() {
        return symptoms;
    }

    public void setSymptoms(Map<String, String> symptoms) {
        this.symptoms = symptoms;
    }

    public List<HealingSymptoms> getSympList() {
        return sympList;
    }

    public void setSympList(List<HealingSymptoms> sympList) {
        this.sympList = sympList;
    }

    public SymptomsDao getSymptomsDao() {
        return symptomsDao;
    }

    public void setSymptomsDao(SymptomsDao symptomsDao) {
        this.symptomsDao = symptomsDao;
    }

    public String getSympId() {
        return sympId;
    }

    public void setSympId(String sympId) {
        this.sympId = sympId;
    }

    public Date getData() {
        return data;
    }

    public void setData(Date data) {
        this.data = data;
    }

    public HealthingDao getHealthingDaoImp() {
        return healthingDaoImp;
    }

    public void setHealthingDaoImp(HealthingDao healthingDaoImp) {
        this.healthingDaoImp = healthingDaoImp;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
    
}
